package command.server;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import model.MessageCommunication;
import server.ClientThread;
import server.Server;

public class GetListOfUsersServer implements CommandServer {

    public GetListOfUsersServer() {
    }

    @Override
    public void execute(ClientThread clientThread) {
        try {
            clientThread.getObjectOutputStream().writeObject(
                    new MessageCommunication(true, "getlistofusersclient"));
            clientThread.getObjectOutputStream().flush();
            clientThread.getObjectOutputStream().writeObject(Server.getUserActiveList());
            clientThread.getObjectOutputStream().flush();
        } catch (IOException ex) {
            Logger.getLogger(GetListOfUsersServer.class.getName()).log(Level.SEVERE,
                    "Fallo al realizar el envío de la lista de usuarios a los clientes", ex);
        }
    }
}
